﻿#ifndef X86_H
#define X86_H

#include "pagetype.h"

using PageItemX86 = std::pair<uint64_t, x86_Page>;
template <int N>
struct PTE_x86
{
	PageItemX86 items[N];
};

class TLB_x86 : public TLB
{
private:
	uint64_t cr3;
	PTE_x86<16> l1i_4k[8], l1i_2m;
	PTE_x86<8> l1d_4k[8], l1d_2m[4], l1d_1g;
	PTE_x86<8> l2_4k[256], l2_2m[128], l2_1g[128];
	void l1i_search();
	void l1d_search();
	void l2_search();
	void swap();

public:
	TLB_x86() = default;
	~TLB_x86() = default;
	void init(uint64_t cr3) { this->cr3 = cr3; }
	void tick();
	void reset();
};

#endif